package com.qf.exc;

import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Wy
 * @version V1.0
 * @Project MavenDemo
 * @Package com.qf.exc
 * @Description:
 * @Date 2022/6/8 19:43
 */
public class MyExceptionResolver implements HandlerExceptionResolver {
    @Override
    public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) {
        ModelAndView modelAndView = new ModelAndView();
        //打印异常堆栈信息到日志
        e.printStackTrace();
        //返回给用户的提示信息
        modelAndView.addObject("error", "不好意思网络繁忙");
        //设置页面的位置
        modelAndView.setViewName("error1");

        return modelAndView;
    }
}
